home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1996 April / Macworld (1996-04).dmg / Educational Demos / Encyclopedia of Nature / DATA / contentM.dir / 00062_Script_62 < prev    next >
Text File  |  1995-04-13  |  4KB  |  100 lines

  1. on moveSlider scrollSprite,Tbutn,TSNum,topCovr,textHt
  2.   global maxSteps,stepCounter,txtLocV,theTop,theBot
  3.   --ïï trackSprite No = TSnum , thumb button = Tbtn , text = scrollSprite 
  4.   --ïï topcovr = cast defining top of window,textHt = leading    
  5.   setUpGlobals  scrollSprite,Tbutn,TSNum,topCovr,textHt
  6.   repeat while the stilldown
  7.     set the locv of sprite Tbutn to the mouseV
  8.     if the mouseV < theTop then
  9.       set the locv of sprite Tbutn to theTop
  10.     end if
  11.     if the mouseV > theBot then
  12.       set the locv of sprite Tbutn to theBot
  13.     end if
  14.     updatestage
  15.     put setTextSpriteLoc(Tbutn,TSNum,textHt) into stepCounter
  16.     set the locv of sprite scrollSprite to txtLocV -textHt* stepCounter
  17.     updatestage
  18.   end repeat
  19. end
  20.  
  21. on setTextSpriteLoc Tbutn,TSNum,textH
  22.   global maxSteps,stepCounter,theTop,theBot,theRange,totScroll,Steps
  23.   --ïï force floating point presion on maths functions
  24.   put the locv of sprite Tbutn - the top of sprite TSNum  - (the height of sprite value(Tbutn))/2 into y1
  25.   put y1*1.00/theRange into y3
  26.   -- ïï y3 now holds the fraction traversed
  27.   put integer(maxSteps*y3) into y6
  28.   return y6
  29. end
  30.  
  31.  
  32.  
  33. on scrollIt UpORdown,downCast,scrollSprite,Tbutn,TSNum,topCovr,textHt
  34.   --ïï use line by line scrolling based on txtHeight = 18 normally
  35.   global maxSteps,stepCounter,txtLocV,theTop,theBot
  36.   put the clickOn into me 
  37.   set upCastNum to the castNum of sprite me
  38.   set the castNum of sprite me to downCast
  39.   updateStage
  40.   put the height of sprite scrollSprite into theHT
  41.   
  42.   setUpGlobals scrollSprite,Tbutn,TSNum,topCovr,textHt
  43.   
  44.   repeat while the stilldown
  45.     put the locv of sprite scrollSprite into yPos
  46.     --ïï increment
  47.     if UpORDown = "up" then
  48.       put stepCounter - 1 into stepCounter
  49.       if stepCounter < 0 then
  50.         put 0 into stepCounter
  51.       end if
  52.     else if UpORDown = "down" then
  53.       put stepCounter + 1 into stepCounter
  54.       if stepCounter > maxSteps then
  55.         put maxSteps into stepCounter
  56.       end if
  57.     end if
  58.     set the locv of sprite scrollSprite to txtLocV -textHt* stepCounter
  59.     updatestage
  60.     
  61.     put setBtnSpriteLoc(stepCounter,TSNum,Tbutn) into theVloc
  62.     set the locV of sprite Tbutn to theVloc
  63.     updatestage
  64.   end repeat
  65.   set the castNum of sprite me to upCastNum
  66.   updatestage
  67. end
  68.  
  69.  
  70. on setUpGlobals  scrollSprite,Tbutn,TSNum,topCovr,textHt
  71.   global maxSteps,theTop,theBot,theRange,totScroll,Steps
  72.   
  73.   put the height of sprite value(scrollSprite) into totScroll
  74.   --ïï deduct the height of the display area approx = ht of trackSprite - overlap with sprite  topCovr at the top of the scrolling window
  75.   
  76.   put the height of sprite value( TSNum ) + 2*(the bottom of sprite topCovr - the top of sprite  value( TSNum )) into dispHt
  77.   put totScroll - dispHt  into totScroll
  78.   
  79.   put  totScroll/textHt into maxSteps
  80.   
  81.   put (the height of sprite value(Tbutn))/2 into HBtnHt
  82.   put the top of sprite value(TSnum) into TStop
  83.   put the bottom of sprite value(TSnum) into TSbot
  84.   put TStop + HBtnHt + 1 into theTop
  85.   put TSbot - HBtnHt   into theBot
  86.   put the height of sprite value(TSnum) - 2*HBtnHt into theRange
  87. end
  88.  
  89. on setBtnSpriteLoc stepCounter,TSNum,Tbutn
  90.   global maxSteps,theTop,theBot,theRange,totScroll,Steps
  91.   --ïï work out percentage of scroll bar traversed
  92.   --ïï force floating point presion on maths functions
  93.   
  94.   put stepCounter*1.00/maxSteps into y3
  95.   --ïï y3 now holds the fraction traversed
  96.   put integer (y3 * theRange) into y5
  97.   put the top of sprite  TSNum + y5 + (the height of sprite value(Tbutn))/2  into y6
  98.   return y6
  99. end
  100.